package com.zrrd.network.inetAddress;

import java.io.IOException;
import java.net.InetAddress;

/**
 * @author WanJl
 * @version 1.0
 * @title InterAddressDemo01
 * @description
 * @create 2023/10/15 16:42
 */
public class InetAddressDemo01 {
    public static void main(String[] args) throws IOException {

        InetAddress address = InetAddress.getByName("www.zrrd.net.cn");

        //public String getHostName()：获取此IP地址的主机名
        String name = address.getHostName();
        //public String getHostAddress()：返回文本显示中的IP地址字符串
        String ip = address.getHostAddress();

        boolean reachable = address.isReachable(200);
        System.out.println("是否能够连接到zrrd官网："+reachable);


        System.out.println("主机名：" + name);
        System.out.println("IP地址：" + ip);
    }
}
